//
//  ICCollectionModel.m
//  ICome
//
//  Created by 席鹏飞 on 16/10/10.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICCollectionModel.h"
#import "ICVideoManager.h"

@implementation ICCollectionModel

- (void)setType:(NSString *)type {
    if ([type isEqualToString:@"1"]) {
        _type = TypeText;
    } else if ([type isEqualToString:@"2"]) {
        _type = TypeVoice;
    } else if ([type isEqualToString:@"3"]) {
        _type = TypePic;
    } else if ([type isEqualToString:@"4"]) {
        _type = TypeVideo;
    } else if ([type isEqualToString:@"5"]) {
        _type = TypeFile;
    } else if ([type isEqualToString:@"7"]) {
        _type = TypePicText;
    } else if ([type isEqualToString:@"9"]) {
        _type = TypeDrtNews;
    }
}

- (void)setImageModel:(ICCollectionImageModel *)imageModel {
    NSDictionary *dict = [NSDictionary dictionaryWithJsonString:self.lnk];
    ICCollectionImageModel *iModel = [[ICCollectionImageModel alloc] init];
    iModel.width = [dict[@"w"] intValue];
    iModel.height = [dict[@"h"] intValue];
    _imageModel = iModel;
}

- (void)setVideoModel:(ICCollectionVideoModel *)videoModel {
    NSDictionary *dict = [NSDictionary dictionaryWithJsonString:self.lnk];
    ICCollectionVideoModel *vModel = [[ICCollectionVideoModel alloc] init];
    vModel.width = [dict[@"w"] intValue];
    vModel.height = [dict[@"h"] intValue];
    vModel.imageKey = dict[@"id"];
    vModel.time = [NSString stringWithFormat:@"%.2f", [dict[@"t"] floatValue] / 1000];
    vModel.fileKey= self.key;
    NSString *path = [[ICVideoManager shareManager] videoPathWithFileName:self.key fileDir:kDiscvoerVideoPath];
    vModel.locVideoPath = path;
    _videoModel = vModel;
}

- (void)setFileModel:(ICCollectionFileModel *)fileModel {
    NSDictionary *dict = [NSDictionary dictionaryWithJsonString:self.lnk];
    ICCollectionFileModel *fModel = [[ICCollectionFileModel alloc] init];
    fModel.fileSize = [dict[@"s"] intValue];
    fModel.fileType = dict[@"x"];
    fModel.fileName = dict[@"n"];
    _fileModel = fModel;
}

- (void)setPicTextModel:(ICCollectionPicTextModel *)picTextModel {
    NSDictionary *dict = [NSDictionary dictionaryWithJsonString:self.key];
    ICCollectionPicTextModel *pModel = [[ICCollectionPicTextModel alloc] init];
    pModel.filekey = dict[@"filekey"];
    pModel.summary = dict[@"summary"];
    pModel.source = dict[@"source"];
    _picTextModel = pModel;
}

-(void)setDrtNewsModel:(ICCollectionDrtNewsModel *)drtNewsModel {
    NSDictionary *dict = [NSDictionary dictionaryWithJsonString:self.key];
    ICCollectionDrtNewsModel *model = [ICCollectionDrtNewsModel mj_objectWithKeyValues:dict];
    _drtNewsModel = model;
}
@end






















